package com.atguigu.gmall.model.user;

import com.atguigu.gmall.model.base.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;

@Data
@ApiModel(description = "userInfo")
@TableName("user_info")
public class UserInfo extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @Length(min = 3, max = 20, message = "用户名长度必须在3-20之间")
    @ApiModelProperty(value = "用户名称")
    @TableField("login_name")
    private String loginName;
    @Length(min = 3, max = 20, message = "用户名长度必须在3-20之间")
    @ApiModelProperty(value = "用户昵称")
    @TableField("nick_name")
    private String nickName;
    @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$", message = "密码必须含有数字和字母，且长度为大于6位")
    @ApiModelProperty(value = "用户密码")
    @TableField("passwd")
    private String passwd;
    @Length(min = 1, max = 20, message = "用户名长度必须在1-20之间")
    @ApiModelProperty(value = "用户姓名")
    @TableField("name")
    private String name;
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    @ApiModelProperty(value = "手机号")
    @TableField("phone_num")
    private String phoneNum;
    @Email(message = "邮箱格式不正确")
    @ApiModelProperty(value = "邮箱")
    @TableField("email")
    private String email;

    @ApiModelProperty(value = "头像")
    @TableField("head_img")
    private String headImg="1";

    @ApiModelProperty(value = "用户级别")
    @TableField("user_level")
    private String userLevel="1";

    @TableField(exist = false)
    private String ipAddress;

}
